import excel 


egen country = group(A)
egen year = group(B)

xtset country year, yearly



generate globalismmm = 0
replace globalismmm = 1 if year>8

gen manshare5ya_1=L.manshare5ya

///ORIGINAL SPECIFICATION


xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, augment 

xtmg manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, augment 

xtdcce2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm (manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm ), crosssectional(lngdpcapitapppnew lngdpcapitapppsqnew lnovererval)




//ROBUSTNESS CHECK, RER_UNADJUSTED
set matsize 450
xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, augment 
xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, augment //ROBUSTNESS CHECK, RER_UNADJUSTED
xtreg manshare5ya lngdpcapitanew lngdpcapitasqnew lnplgdpo5yanew globalismmm, fe robust //Important
xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, fe robust //Important



xtmg manshare5ya lnovererval globalismmm, augment 


xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, fe
xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, fe robust

xtreg manshare5ya lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, fe
xtreg manshare5ya lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, fe robust //Important


//robustness check with lnRER_cpi

ipolate RER_cpi year, gen(RER_cpi_ipolated) epolate by(country)

gen lnRER_cpi_ipolated = ln(RER_cpi_ipolated)

xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnRER_cpi_ipolated globalismmm, fe robust
xtreg manshare5ya lngdpcapitanew lngdpcapitasqnew lnRER_cpi_ipolated globalismmm, fe robust 
xtmg manshare5ya lngdpcapitanew lngdpcapitasqnew lnRER_cpi_ipolated globalismmm, cce
xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnRER_cpi_ipolated globalismmm, cce


xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew RER_cpi_ipolated globalismmm, augment


// RER here defined as (E x PPI_us) / CPI_home where E is specified in TL/$, PPI_us: producer price index for the us, cpi_home: home country's consumer price index. Hence, when RER goes up, it means undervaluation; the nominal exchange rate undergoes a depreciation more than is necessiatated by the increase in inflation

 

//robustness check with lnREER_imf

ipolate REER_imf year, gen(REER_imf_ipolated) epolate by(country)

gen lnREER_imf_ipolated = ln(REER_imf_ipolated)

xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnREER_imf_ipolated globalismmm, fe robust
xtreg manshare5ya lngdpcapitanew lngdpcapitasqnew lnREER_imf_ipolated globalismmm, fe robust 
xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnREER_imf_ipolated globalismmm, augment 
xtmg manshare5ya lngdpcapitanew lngdpcapitasqnew lnREER_imf_ipolated globalismmm, augment 




//2-step difference and system GMM
gen manshare5ya_1=L.manshare5ya
gen lnoverval_1=L.lnovererval

gen lnoverval_sq=lnovererval*lnovererval
xtmg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew  lnoverval_1 globalismmm, augment 


quietly tab year, gen(year)



//coefficent before overval significant and negative but its treated as exogenous
xtabond2 manshare5ya manshare5ya_1 lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(3 9))  iv(lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, equation(level)) twostep  small ortho
xtabond2 manshare5ya manshare5ya_1 lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(3 9))  iv(lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, equation(diff)) twostep  small ortho


//LNOVERVAL

//coefficient before overval significant and negative, and its treated as endogenous plus globalism dummy significant and negative


//SYSTEM GMM: 
xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(1 5) collapse) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small ortho //Forward orthogonal deviations trasnformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small  // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small robust // first difference transformation


xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(2 4)) gmm(lnovererval, lag (1 3) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(both))  twostep  small robust // first difference transformation //Windmeijer's finite sample correction to 2-step SEs

////with time dummies
xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval year2-year12 globalismmm, gmm(manshare5ya_1, lag(3 5)) gmm(lnovererval, lag (3 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(diff)) twostep  small ortho 

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval year2-year12, gmm(manshare5ya_1, equation(diff) lag(2 5)) gmm(lnovererval, equation(diff) lag(1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) twostep  small  // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval year2-year12, gmm(manshare5ya_1, equation(diff) lag(2 5)) gmm(lnovererval, equation(diff) lag(1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) twostep  small robust // first difference transformation


//DIFFERENCE GMM
xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnovererval, lag (2 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) noleveleq twostep small ortho //Forward orthogonal deviations trasnformation


xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) noleveleq twostep small // first difference transformation


xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) noleveleq twostep small robust // first difference transformation //Windmeijer's finite sample correction to 2-step SEs

//// with time dummies added
xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval year2-year12 globalismmm, gmm(manshare5ya_1, lag(3 5)) gmm(lnovererval, lag (3 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(diff)) noleveleq twostep  small ortho 

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval year2-year12, gmm(manshare5ya_1, lag(2 5) collapse) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) noleveleq twostep  small  // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnovererval year2-year12, gmm(manshare5ya_1, lag(2 5) collapse) gmm(lnovererval, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) noleveleq twostep  small robust // first difference transformation //Windmeijer's finite sample correction to 2-step SEs


//UNADJUSTED RER

//SYSTEM GMM
xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (2 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small ortho ////Forward orthogonal deviations trasnformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small robust // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 4)) gmm(lnplgdpo5yanew, lag (1 4) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) twostep  small robust // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 4)) gmm(lnplgdpo5yanew, lag (1 3) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(both))  twostep  small robust // first difference transformation //Windmeijer's finite sample correction to 2-step SEs

//// with time dummies added

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12 globalismmm, gmm(manshare5ya_1, lag(3 5)) gmm(lnplgdpo5yanew, lag (3 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(diff)) twostep  small ortho 

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12, gmm(manshare5ya_1, lag(3 5)) gmm(lnplgdpo5yanew, lag (3 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) twostep  small ortho 


xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12, gmm(manshare5ya_1, lag(2 5) equation(diff)) gmm(lnplgdpo5yanew, lag (1 5) equation(diff) collapse)  iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) twostep  small  // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12, gmm(manshare5ya_1, lag(2 5) equation(diff)) gmm(lnplgdpo5yanew, lag (1 5) equation(diff) collapse)  iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) twostep  small robust  // first difference transformation //Windmeijer's finite sample correction to 2-step SEs


//DIFFERENCE GMM

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (2 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) noleveleq twostep  small ortho //Forward orthogonal deviations trasnformation


xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) noleveleq twostep  small // first difference transformation

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew globalismmm, gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew globalismmm, equation(diff)) noleveleq twostep  small robust // first difference transformation

//// with time dummies added

xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12 globalismmm, gmm(manshare5ya_1, lag(3 5)) gmm(lnplgdpo5yanew, lag (3 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12 globalismmm, equation(diff)) noleveleq twostep  small ortho 
xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12 , gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) noleveleq twostep  small  // first difference transformation


xtabond2 manshare5ya manshare5ya_1 lngdpcapitapppnew lngdpcapitapppsqnew lnplgdpo5yanew year2-year12 , gmm(manshare5ya_1, lag(2 5)) gmm(lnplgdpo5yanew, lag (1 5) collapse) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(level)) iv(lngdpcapitapppnew lngdpcapitapppsqnew year2-year12, equation(diff)) noleveleq twostep  small robust // first difference transformation //Windmeijer's finite sample correction to 2-step SEs






//slope homogeneity test// Pesaran, Yamagata. 2008. Journal of Econometrics
xthst manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm





 
 
gen llnovererval=L.lnovererval

xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, fe
estimates store fe 
xtivreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew globalismmm (lnovererval=llnovererval), fe
estimates store fe_iv 
dmexogxt lnovererval 

clear


import excel "C:\Users\sait.cakir\Desktop\premature deindustrialization\data\data expansion\outliers excluded\data up to 2017\10 year averages-negcor overval\WS negcor 5-ya data 1960-2017.xlsx", sheet("Sheet1") firstrow



egen country = group(A)
egen year = group(B)

xtset country year, yearly



generate globalismmm = 0
replace globalismmm = 1 if year>8


gen llnovererval=L.lnovererval

xtmg manshare5ya lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, augment

xtreg manshare5ya lngdpcapitanew lngdpcapitasqnew lnovererval globalismmm, fe
estimates store fe 
xtivreg manshare5ya lngdpcapitanew lngdpcapitasqnew globalismmm (lnovererval=llnovererval), fe
estimates store fe_iv 
dmexogxt lnovererval 








//Cross-Section dependency test for large T small N use Breusch Pagan (xttest2) but for small T large N use xtcsd

xtreg manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, fe
xtcsd, pesaran show



//2nd generation Unit root test



multipurt manshare5ya, lags (3)
pescadf manshare5ya, lags (2)

multipurt lngdpcapitapppnew, lags (3)
pescadf lngdpcapitapppnew, lags (1)

multipurt lnovererval, lags(3)
pescadf lnovererval, lags (1) trend


//cointegration (ECM-based) Westerlund (2007), Ho: no cointegration

xtwest manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm , lags(0 0) leads(0 0) lrwindow(3) constant trend 

set matsize 10000
xtwest manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm , lags(0 0) lrwindow(3) bootstrap(800)


//cointegration, Westerlund (2005)

xtcointtest westerlund manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm,  allpanels
xtcointtest westerlund manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, trend allpanels
xtcointtest westerlund manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm, trend
xtcointtest westerlund manshare5ya lngdpcapitapppnew lngdpcapitapppsqnew lnovererval globalismmm

    
   
// hadri unit root test, Ho: stationarity Ha: unit root         

xtunitroot hadri manshare5ya, robust
xtunitroot hadri manshare5ya, demean robust
xtunitroot hadri manshare5ya, trend demean robust

xtunitroot hadri lnovererval, robust
xtunitroot hadri lnovererval, demean robust
xtunitroot hadri lnovererval, trend demean robust

xtunitroot hadri lngdpcapitapppnew, robust
xtunitroot hadri lngdpcapitapppnew, demean robust
xtunitroot hadri lngdpcapitapppnew, trend demean robust 




